package com.hmall.cart;

import com.hmall.api.config.DefaultFeignConfig;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
//接下来，我们在cart-service的CartApplication启动类上添加注解，启动OpenFeign功能
//@EnableFeignClients 这是第一步     方式1：声明扫描包 在cart-service的启动类上添加声明即可

//4.4.2.配置  - 局部生效：在某个FeignClient中配置，只对当前FeignClient生效  在某个FeignClient中配置，只对当前FeignClient生效
//@FeignClient(value = "item-service", configuration = DefaultFeignConfig.class)

//或者声明要用的FeignClient 全局生效：在启动类上添加注解，开启OpenFeign功能
@EnableFeignClients(basePackages = "com.hmall.api.client", defaultConfiguration = DefaultFeignConfig.class)


//@EnableFeignClients(clients = {com.hmall.api.client.ItemClient.class})
@MapperScan("com.hmall.cart.mapper")
@SpringBootApplication
public class CartApplication {
    public static void main(String[] args) {
        SpringApplication.run(CartApplication.class, args);
    }

    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}